//=============================================================================
#ifndef _CCLIENTS_H_
    #define _CCLIENTS_H_

#include <string>
#include <vector>

#include <windows.h>

#include <SDL.h>
#include <SDL_net.h>
#include <SDL_Thread.h>

#include "CNetworkPacket.h"
#include "CNetworkStream.h"
#include "CClientsFiles.h"

#include <net2.h>

//=============================================================================
enum {
    CCLIENTS_MODE_LOGIN = 0,
    CCLIENTS_MODE_GETFILELIST,
    CCLIENTS_MODE_SENDFILES,
    CCLIENTS_MODE_ENTER_WORLD,
    CCLIENTS_MODE_UPDATE
};

//=============================================================================
class CClients {
	public:
		static CClients             Clients[MAX_CLIENTS];
    public:
        std::string                 UID;
        int                         PlayerID;

        std::vector<CClientsFiles>  Files;
        std::vector<CNetworkPacket> Packets;

        unsigned long int           LastUpdate;

	private:
		int	Socket;

		int Mode;

	public:
		CClients();

		void Connect(int Socket);

		void Disconnect();

		bool IsAvailable();

    public:
		CNetworkPacket* GetReadPacket();

		int GetSocket();

    public:
		int GetMode();

		void SetMode(int Mode);

    public:
        void ScanFiles(std::string Path = "");

	public:
		static CClients* FindAvailable();

		static CClients* FindBySocket(int Socket);

	public:
		static bool OnInit();
};

//=============================================================================

#endif
